package com.hmsproject.rest;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.core.Response;
import javax.ws.rs.Produces;
import javax.ws.rs.PathParam;

import com.hmsproject.db.util.HMSDBUtil;
import com.sun.jersey.api.view.Viewable;

@Path("/hmsrest")
public class VerifyHMSUserHandler {
	
	@GET
	@Produces ("text/html")
	@Path("/verifyUser/{param}")
	public Response verifyHMSUser(@PathParam("param") String verificationcode) throws Exception{
		
		Response response = null;

		boolean result = HMSDBUtil.getInstance().verifyUser(verificationcode);
		
		if(result){
			response = Response.ok(new Viewable("/user/userVerification.xhtml")).build(); 
		}else{
			response = Response.ok(new Viewable("/user/userVerificationWrong.xhtml")).build(); 
		}
		
		return response;
	}
	
	@GET
	@Produces ("text/html")
	@Path("/showDeal/{param}")
	public Response showHMSDeal(@PathParam("param") String dealId) throws Exception{
		
		System.out.println("DealID:   " + dealId);
		
		Response response = Response.ok(new Viewable("/deal/viewHotel.xhtml?dealId="+dealId)).build(); 
		
		return response;
	}	

}
